package com.finance.report.controller;

import com.finance.framework.controller.BaseController;
import com.finance.framework.controller.Result;
import com.finance.framework.lang.Page;
import com.finance.framework.lang.PageResultBO;
import com.finance.report.bean.pojo.PieceResultList;
import com.finance.report.bean.pojo.WeightResultList;
import com.finance.report.request.PieceResultListReq;
import com.finance.report.request.WeightResultListReq;
import com.finance.report.service.ICalculateResultService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * Created by liyue on 2017/8/21.
 */
@Controller
@RequestMapping("/report/calculate")
public class CalculateResultController extends BaseController {

    @Resource
    private ICalculateResultService calculateResultService;

    @RequestMapping("/piece/index")
    public String pieceIndex() {
        return "report/calculateResultCompare/pieceResult";
    }

    @RequestMapping("/weight/index")
    public String weightIndex() {
        return "report/calculateResultCompare/weightResult";
    }

    @RequestMapping("/suffixs")
    public Result suffixs() {
        List<Map<String,String>> suffixList = calculateResultService.suffixList();
        return getSuccessResult(suffixList);
    }

    @RequestMapping("/list/piece")
    public Result pieceList(PieceResultListReq form) {
        Page page = Page.getInstance(form);
        PieceResultList pieceResultList = new PieceResultList();
        pieceResultList.setWorkNo(form.getWorkNo());
        pieceResultList.setRealName(form.getRealName());
        pieceResultList.setOrgName(form.getOrgName());
        pieceResultList.setCarrierName(form.getCarrierName());
        pieceResultList.setSupplierName(form.getSupplierName());
        pieceResultList.setToProvinceName(form.getToProvinceName());
        pieceResultList.setSuffix(form.getSuffix());
        pieceResultList.setResultType(form.getResultType());
        page.setParams(pieceResultList);
        PageResultBO<PieceResultList> resultBO = calculateResultService.pieceListByPage(page);
        return getSuccessResult(resultBO);
    }

    @RequestMapping("/list/weight")
    public Result weightList(WeightResultListReq form) {
        Page page = Page.getInstance(form);
        WeightResultList weightResultList = new WeightResultList();
        weightResultList.setWorkNo(form.getWorkNo());
        weightResultList.setRealName(form.getRealName());
        weightResultList.setOrgName(form.getOrgName());
        weightResultList.setCarrierName(form.getCarrierName());
        weightResultList.setSupplierName(form.getSupplierName());
        weightResultList.setToProvinceName(form.getToProvinceName());
        weightResultList.setSuffix(form.getSuffix());
        page.setParams(weightResultList);
        PageResultBO<WeightResultList> resultBO = calculateResultService.weightListByPage(page);
        return getSuccessResult(resultBO);
    }

}
